/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * EliminarProducto.java
 *
 * Created on 19/05/2010, 10:10:35 PM
 */

package ui;

import acceso.Administrador;
import acceso.Catalogo;
import acceso.Pedido;
import acceso.Producto;
import acceso.Proveedor;
import acceso.Venta;
import gestion.GestionSpring;
import interfaz.InterfaceEjp;
import java.util.List;
import javax.swing.JOptionPane;

/**
 *
 * @author Adriano
 */
public class EliminarProducto extends javax.swing.JFrame {

    Long    Codigo;
    String Nombre;
    PaginaPrincipal miPaginaPrincipal;

    public void setMiPaginaPrincipal(PaginaPrincipal miPaginaPrincipal) {
        this.miPaginaPrincipal = miPaginaPrincipal;
        NombreProductoEliminar.setText(Nombre);
    }

    public void setCodigo(Long Codigo) {
        this.Codigo = Codigo;
    }

   

    public void setNombre(String Nombre) {
        this.Nombre = Nombre;
    }

       public String getNombre() {
        return Nombre;
    }






    /** Creates new form EliminarProducto */
    public EliminarProducto() {
        initComponents();

    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jButton1 = new javax.swing.JButton();
        jPanel1 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        NombreProductoEliminar = new javax.swing.JLabel();
        BotonSiElminar = new javax.swing.JButton();
        BotonNoEliminar = new javax.swing.JButton();

        jButton1.setText("Mostrar");
        jButton1.setName("jButton1"); // NOI18N
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Inversiones E.J.P");

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Eliminar Producto"));
        jPanel1.setName("jPanel1"); // NOI18N

        jLabel1.setFont(new java.awt.Font("Tahoma", 0, 12));
        jLabel1.setText("¿Esta seguro que desea eliminar este producto?");
        jLabel1.setName("jLabel1"); // NOI18N

        NombreProductoEliminar.setFont(new java.awt.Font("Tahoma", 0, 14));
        NombreProductoEliminar.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        NombreProductoEliminar.setText("jLabel2");
        NombreProductoEliminar.setName("NombreProductoEliminar"); // NOI18N

        BotonSiElminar.setText("Si");
        BotonSiElminar.setName("BotonSiElminar"); // NOI18N
        BotonSiElminar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BotonSiElminarActionPerformed(evt);
            }
        });

        BotonNoEliminar.setText("No");
        BotonNoEliminar.setName("BotonNoEliminar"); // NOI18N
        BotonNoEliminar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BotonNoEliminarActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                            .addComponent(NombreProductoEliminar, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(87, 87, 87)
                        .addComponent(BotonSiElminar)
                        .addGap(18, 18, 18)
                        .addComponent(BotonNoEliminar)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(NombreProductoEliminar)
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(BotonSiElminar)
                    .addComponent(BotonNoEliminar))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
        setBounds((screenSize.width-331)/2, (screenSize.height-193)/2, 331, 193);
    }// </editor-fold>//GEN-END:initComponents


    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
      
    }//GEN-LAST:event_jButton1ActionPerformed

    private void BotonSiElminarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BotonSiElminarActionPerformed

        //Eliminarmos el producto seleccionado.
        InterfaceEjp miInterfaceEjp = GestionSpring.getSingleton().MetodoGestion();
        miInterfaceEjp.EliminarProducto(Codigo);
        JOptionPane.showMessageDialog(this, "Eliminacion Exitosa");
        //Refrescamos el JTable TablaProducto.
        miPaginaPrincipal.Refrescar();
        this.setVisible(false);

    }//GEN-LAST:event_BotonSiElminarActionPerformed

    private void BotonNoEliminarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BotonNoEliminarActionPerformed
       
        this.setVisible(false);

    }//GEN-LAST:event_BotonNoEliminarActionPerformed

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new EliminarProducto().setVisible(true);

            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton BotonNoEliminar;
    private javax.swing.JButton BotonSiElminar;
    private javax.swing.JLabel NombreProductoEliminar;
    private javax.swing.JButton jButton1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JPanel jPanel1;
    // End of variables declaration//GEN-END:variables

}
